import sys
from os import path


def readContent(fileName):
    with open(fileName, 'r') as f:
        return f.read()


def getFilePath(fileName):
    bundle_dir = get_base_path()
    return path.abspath(path.join(bundle_dir, fileName))


def get_base_path():
    # 是否Bundle Resource
    if getattr(sys, 'frozen', False):
        # 单个exe解药后的路径
        return sys._MEIPASS
    else:
        # 不打包，正常执行的路径
        return path.abspath(".")
